Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pam: also set teleport-specific env vars via pam_putenv #3725

Merged
merged 2 commits into from
May 19, 2020
Merged

Conversation

awly
Copy link
Contributor

@awly awly commented May 15, 2020

Using pam_putenv from libpam exposes these env vars to pam_exec.so
and possibly other built-in PAM modules. Keep setting them via
os.Setenv too, for pam_script.so to use.

Updates #3692

Using `pam_putenv` from `libpam` exposes these env vars to `pam_exec.so`
and possibly other built-in PAM modules. Keep setting them via
`os.Setenv` too, for `pam_script.so` to use.

Updates #3692

// Also set it via PAM-specific pam_putenv, which is respected by
// pam_exec (and possibly others), where parent env vars are not.
kv := C.CString(fmt.Sprintf("%s=%s", k, v))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C.CString does a malloc under the hood. Will PAM free this memory? If not you'll need to call C.free yourself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice catch, added C.free.
First time using cgo, appreciate all the advice!

// Also set it via PAM-specific pam_putenv, which is respected by
// pam_exec (and possibly others), where parent env vars are not.
kv := C.CString(fmt.Sprintf("%s=%s", k, v))
retval := C._pam_putenv(pamHandle, p.pamh, kv)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put pam_putenv have any maximum size? If so you might want to cap the length here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http://www.linux-pam.org/Linux-PAM-html/adg-interface-by-app-expected.html#adg-pam_putenv doesn't mention any limits and their source code seems to allocate as much as needed.

@awly awly merged commit 9d33512 into master May 19, 2020
@awly awly deleted the andrew/pam-putenv branch May 19, 2020 20:09
awly pushed a commit that referenced this pull request May 21, 2020
With #3725 we now populate teleport-specific env vars in a way that's
accessible to `pam_exec.so`. There's no longer any reason to install
pam_script.so separately and duplicate our docs.

Updates #3692
awly pushed a commit that referenced this pull request May 21, 2020
With #3725 we now populate teleport-specific env vars in a way that's
accessible to `pam_exec.so`. There's no longer any reason to install
pam_script.so separately and duplicate our docs.

Updates #3692
awly pushed a commit that referenced this pull request May 21, 2020
With #3725 we now populate teleport-specific env vars in a way that's
accessible to `pam_exec.so`. There's no longer any reason to install
pam_script.so separately and duplicate our docs.

Updates #3692
awly pushed a commit that referenced this pull request May 21, 2020
With #3725 we now populate teleport-specific env vars in a way that's
accessible to `pam_exec.so`. There's no longer any reason to install
pam_script.so separately and duplicate our docs.

Updates #3692
benarent added a commit that referenced this pull request Jun 18, 2020
* Base fork for 4.3 docs

* [docs] external email identities and Kube Users (#3628)

* Base fork for 4.3 docs

* [docs] external email identities and Kube Users (#3628)

* Remove trailing whitespace from docs files

Some editors will do this automatically on save. This causes a lot of
diffs when editing the docs in such an editor.
Clean them up once now and we'll try to keep it tidy going forward.

* Add make rules for docs whitespace and milv

docs-test-whitespace: checks for trailing whitespace in all .md files
  under docs/.
docs-fix-whitespace: removes trailing whitespace in all .md files under
  docs/.
docs-test-links: runs milv in all docs/ subdirectories that have
  milv.config.yaml.
docs-test: runs whitespace and links tests, used during `make docs`

* Document the new `--use-local-ssh-agent` flag for tsh

The flag is used to bypass the local SSH agent even when it's running.
Specifically, this helps with agents that don't support certs.

The flag was added in #3721

* Remove pam_script.so docs from SSH PAM page

With #3725 we now populate teleport-specific env vars in a way that's
accessible to `pam_exec.so`. There's no longer any reason to install
pam_script.so separately and duplicate our docs.

Updates #3692

* Using the correct --insecure-no-tls flag

* Run docs-fix-whitespace make rule in a busybox container


* Fixes #3414

Co-authored-by: Andrew Lytvynov <andrew@gravitational.com>
Co-authored-by: Gus Luxton <gus@gravitational.com>
Co-authored-by: Steven Martin <steven@gravitational.com>
Co-authored-by: Gus Luxton <webvictim@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants